<template>
  <div class="questionnair_list">
    <navigate>问卷测评列表</navigate>
    <div>
      <div class="questionnair_tit">{{ name }}</div>
      <div class="questionnair_num">本任务含分卷：{{ qnEvalLis.length }}份</div>
      <div class="list_box">
        <div class="item_info" v-for="(item, index) in qnEvalLis" :key="index">
          <div class="dis_flex">
            <img src="@/assets/images/common/bar.png" alt="" class="bar_img" />
            <div class="item_tit">{{ item.paper_name }}</div>
          </div>
          <div class="item_line"></div>
          <div class="dis_flex just_space_between">
            <div>
              <div class="item_txt">限时：{{ item.paper_time_limited }}</div>
              <div class="item_txt mar_top8">
                计分：{{ item.paper_total_score }}分/{{
                  item.paper_topic_num
                }}题
              </div>
            </div>
            <div class="dis_flex" v-if="item.is_finish == 1">
              <img
                src="@/assets/images/common/success_icon.png"
                alt=""
                class="fish_img"
              />
              <div class="fish_txt">已完成</div>
            </div>
            <div class="item_btn" v-else @click="checkDet(item.id)">
              进入测评
            </div>
          </div>
        </div>
      </div>

      <div class="deadline">
        -- 任务截止：
        {{ deadline ? convertTimestampToDateTime(deadline) : "" }}
        --
      </div>
    </div>
  </div>
</template>

<script>
import { convertTimestampToDateTime } from "@/utils/time.js";
import { queryQnEvalList } from "@/api/evaluation/questionnaire";
export default {
  data() {
    return {
      qnEvalLis: [],
      name: "",
      deadline: "",
    };
  },
  created() {
    this.name = this.$route.query.name;
    this.deadline = this.$route.query.deadline;
    this.getQnEvalList();
  },
  methods: {
    convertTimestampToDateTime,
    async getQnEvalList() {
      let res = await queryQnEvalList({ id: this.$route.query.id });
      if (res.code === 200) {
        this.qnEvalLis = res.data;
      }
    },
    checkDet(id) {
      this.$router.push(`/questionnaireDetails?id=${id}`);
    },
  },
};
</script>

<style lang="less" scoped>
.dis_flex {
  display: flex;
  align-items: center;
}
.just_space_between {
  justify-content: space-between;
}
.flex1 {
  flex: 1;
  min-width: 0;
}
.mar_top8 {
  margin-top: 8px;
}
.questionnair_list {
  color: #333333;
  background-color: #f4f6fa;
}
.list_box {
  margin-top: 26.33px;
}
.item_info {
  padding: 16px 13px;
  border-radius: 6.67px;
  margin: 0 10px 10px 10px;
  background-color: #ffffff;
  &:last-child {
    margin-bottom: 0;
  }
}
.questionnair_tit,
.questionnair_num {
  text-align: center;
}
.questionnair_tit {
  color: #00aeff;
  font-size: 18px;
  line-height: 18px;
  margin: 27.33px 0 13.33px;
}
.questionnair_num {
  font-size: 14px;
  line-height: 14px;
}
.bar_img {
  width: 6.67px;
  height: 16.67px;
  margin-right: 10px;
}
.item_tit {
  color: #333333;
  font-size: 16.67px;
  font-weight: bold;
}
.item_line {
  border-bottom: 0.33px solid rgba(0, 0, 0, 0.2);
  margin: 13px 0;
}
.item_txt {
  color: #666666;
  font-size: 14.67px;
  line-height: 14.67px;
}
.item_btn {
  width: 73.33px;
  height: 33.33px;
  line-height: 33.33px;
  color: #ffffff;
  font-size: 12.67px;
  text-align: center;
  background: linear-gradient(0deg, #ffffff -20%, rgba(255, 255, 255, 0) 20%),
    #0aa7f4;
  border-radius: 6.67px;
}
.fish_img {
  width: 16.33px;
  height: 16px;
  margin-right: 7px;
}
.fish_txt {
  color: #14c76a;
  font-size: 14px;
  line-height: 14px;
}
.deadline {
  color: #888888;
  font-size: 14px;
  line-height: 14px;
  margin: 32px auto;
  text-align: center;
}
</style>
